Repository navigation
fix(agent): warn on fallbacks instead of printing to stdout - #861
Merged
NandhaKishorM merged 1 commit intoOct 2, 2026
Merged
Conversation
The device-fallback, CPU-retry, fast-path, OOM-retry and autocast notes were bare `print()` calls, so they went to stdout. `laya --json` and `laya --batch --json` write their records there, and the MCP server speaks JSON-RPC over stdio, so a fallback interleaved a `Warning: ...` line into a machine-readable stream -- and a caller could not silence it the way a warning filter can. Route all eight through `warnings.warn(..., RuntimeWarning)`, keeping the message text unchanged; the module already used `warnings.warn` elsewhere. Pinned by a new test in tests/test_load_errors.py: a `device="cuda"` load on a CPU-only machine emits a RuntimeWarning and writes nothing to stdout.
Owner
|
Merged for 0.3.24. Eight One integration note: #843 added its own section 7 to Verified on the integrated branch: Thank you. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Eight load- and inference-time notes in
laya/agent.pywere bareprint()calls, so they went to stdout:laya/agent.py:598,:601,:604— requested device unavailable, falling back to CPU:744-752— the model could not be placed on the requested device:782— the fast path is unavailable:841— the model could not be moved back after the CPU retry:1121— a GPU OOM retry:1165— autocast disabled after repeated failuresStdout is a machine-readable stream on three surfaces:
laya --jsonwrites one JSON object,laya --batch --jsonwrites one JSON object per line, and the MCP server speaks JSON-RPC over stdio. A fallback or an OOM retry interleavesWarning: ...into that stream and breaks a strict JSON/JSONL (or JSON-RPC) consumer. A caller also cannot silence aprintthe way it can filter a warning.This routes all eight through
warnings.warn(..., RuntimeWarning), keeping each message text identical. The same module already useswarnings.warnat:105,:679,:1619and:1647.tests/test_load_errors.pygains a check that adevice="cuda"load on a CPU-only machine emits aRuntimeWarningand writes nothing to stdout (the checkpoints build in-process, no network).